/* frontend/src/App.css - 只修改消息宽度部分 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --human-msg-bg: #f0f0f0;
  --assistant-msg-bg: #ffffff;
  --human-msg-color: #000000;
  --assistant-msg-color: #1a1a1a;
  --border-color: #e4e4e4;
  --input-bg: #ffffff;
  --button-bg: #f2f2f2;
  --button-hover: #e6e6e6;
  --primary-color: #5e5adb;
  --primary-hover: #4b48b0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1100px; /* 从1000px增加到1100px */
  margin: 0 auto;
  background-color: var(--bg-color);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.human {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* 用户消息 */
.message-row.human .message {
  max-width: 80%;
  background-color: var(--human-msg-bg);
  color: var(--human-msg-color);
  border-top-right-radius: 0.25rem;
}

/* 助手消息 - 增加宽度 */
.message-row.assistant .message {
  max-width: 90%; /* 从80%增加到90% */
  background-color: var(--assistant-msg-bg);
  color: var(--assistant-msg-color);
  border: 1px solid var(--border-color);
  border-top-left-radius: 0.25rem;
}

.image-preview {
  margin-bottom: 0.75rem;
  border-radius: 0.5rem;
  overflow: hidden;
}

.image-preview img {
  max-width: 100%;
  max-height: 300px;
  display: block;
}

.map-container {
  margin-top: 0.75rem;
  width: 650px;
  height: 500px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.input-container {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-color);
  position: relative;
  display: flex;
  align-items: center;
}

textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 3rem 0.75rem 0.75rem;
  font-size: 1rem;
  resize: none;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-family: inherit;
  overflow: hidden;
}

textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.buttons {
  position: absolute;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background-color: var(--button-bg);
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover:not(:disabled) {
  background-color: var(--button-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-button {
  color: var(--primary-color);
}

.send-button:hover:not(:disabled) {
  color: var(--primary-hover);
}

.upload-button {
  color: #666;
}

.typing-indicator {
  display: flex;
  align-items: center;
  column-gap: 0.25rem;
}

.typing-indicator span {
  background-color: #999;
  border-radius: 50%;
  height: 0.5rem;
  width: 0.5rem;
  display: block;
  opacity: 0.4;
}

.typing-indicator span:nth-child(1) {
  animation: pulse 1s infinite 0s;
}

.typing-indicator span:nth-child(2) {
  animation: pulse 1s infinite 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation: pulse 1s infinite 0.4s;
}

@keyframes pulse {
  0% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
}

/* 自动调整文本框高度 */
textarea {
  overflow-y: hidden;
  min-height: 46px;
  max-height: 200px;
}

@media (max-width: 640px) {
  .message-row.human .message {
    max-width: 90%;
  }

  .message-row.assistant .message {
    max-width: 95%;
  }
}

/* 大屏幕上增加最大宽度 */
@media (min-width: 1200px) {
  .chat-app {
    max-width: 1200px;
  }
}

/* 图片选择和预览样式 */
.selected-images-container {
  padding: 10px;
  margin: 0 1rem 10px;
  background-color: #f7f7f7;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.selected-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.selected-image {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 4px;
  overflow: hidden;
}

.selected-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-image {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  border: none;
}

.upload-selected-button {
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
}

.upload-selected-button:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.images-preview .image-preview {
  max-width: 200px;
  border-radius: 0.5rem;
  overflow: hidden;
}